package com.team9.fitness.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 食物信息实体
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class FoodInfo {
    private Long id;
    private String name; // 食物名称
    private Double calories; // 每100克热量(千卡)
    private Double carbohydrates; // 每100克碳水化合物(克)
    private Double protein; // 每100克蛋白质(克)
    private Double fat; // 每100克脂肪(克)
    private String category; // 食物分类
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;

    public void setCreatedAtIfNull() {
        if (this.createdAt == null) {
            this.createdAt = LocalDateTime.now();
        }
    }

    public void setUpdatedAtIfNull() {
        this.updatedAt = LocalDateTime.now();
    }
}

